package com.leyou.common.advice;

import com.leyou.common.exception.LyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
@RestControllerAdvice
public class GlobalExceptionHandle {
    @ExceptionHandler(LyException.class)
    public ResponseEntity<String> myExceptionHandler(LyException le){
        return ResponseEntity.status(le.getStatus()).body(le.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity<String> handleException(Exception e){
        return ResponseEntity.status(500).body(e.getMessage());
    }
}
